/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.uoc.tdp.pac4.only5.gui.client.model;

import edu.uoc.tdp.pac4.only5.domain.Booking;
import java.util.List;
import javax.swing.table.AbstractTableModel;
import javax.swing.ComboBoxModel;

/**
 *
 * @author Gerard
 */
public class BookingTableModel extends AbstractTableModel {
    
    private List<Booking> elements;
    
    private String[] columns;

    public BookingTableModel(List<Booking> elements, String[] columns) {
        this.elements = elements;
        this.columns = columns;
    }

    @Override
    public int getRowCount() {
        int size = 0;
        if(elements != null){
            size = elements.size();
        }
        return size;
    }

    @Override
    public int getColumnCount() {
        int size = 0;
        if(columns != null){
            size = columns.length;
        }
        return size;
    }

    @Override
    public Object getValueAt(int row, int column) {
        if(elements != null && elements.size() > 0){
            switch(column){
               case 0: return elements.get(row).getId();
               case 1: return elements.get(row).getCustomer();
               case 2: return elements.get(row).getStartTime();
               case 3: return elements.get(row).getEndTime();
               case 4: return elements.get(row).getPax();
               case 5: return elements.get(row).getStatus();
               case 6: return elements.get(row).getCreationTime();
               case 7: return elements.get(row).getCancelTime();
               case 8: return elements.get(row).getCancelUser();
               case 9: return elements.get(row).getRecordDate();
            }
        }
        return null;
    }  
}
